@file:Suppress("unused")

package com.example.demo.model

import com.example.demo.handler.*
import com.example.demo.proxy.*
import xyz.erupt.annotation.*
import xyz.erupt.annotation.sub_field.*
import xyz.erupt.annotation.sub_field.sub_edit.*
import xyz.erupt.jpa.model.*
import java.util.*
import javax.persistence.*
import kotlin.jvm.Transient

@Erupt(
    name = "组件示例",
    dataProxy = [ComponentDataProxy::class],
)
@Table(name = "demo_component")
@Entity
class Component : BaseModel() {

    @EruptField(
        views = [View(title = "文本")],
        edit = Edit(title = "文本", search = Search(vague = true)),
    )
    var input: String? = null

    @EruptField(
        views = [View(title = "数字")],
        edit = Edit(title = "数字", search = Search(vague = true)),
    )
    var number1: Double? = null

    @EruptField(
        views = [View(title = "数字滑块")],
        edit = Edit(title = "数字滑块", type = EditType.SLIDER),
    )
    var slider: Int? = null

    @EruptField(
        views = [View(title = "布尔")],
        edit = Edit(title = "布尔", search = Search()),
    )
    var bool: Boolean? = null

    @EruptField(
        views = [View(title = "自动完成")],
        edit = Edit(
            title = "自动完成",
            search = Search(vague = true),
            type = EditType.AUTO_COMPLETE,
            autoCompleteType = AutoCompleteType(handler = AutoCompleteHandlerImpl::class)
        ),
    )
    var autoComplete: String? = null

    @EruptField(
        views = [View(title = "颜色选择")],
        edit = Edit(title = "颜色选择", search = Search(vague = true), inputType = InputType(type = "color")),
    )
    var color: String? = null

    @EruptField(
        views = [View(title = "周选择器")],
        edit = Edit(title = "周选择器", search = Search(vague = true), inputType = InputType(type = "week")),
    )
    var weekInput: String? = null

    @ManyToOne
    @EruptField(
        edit = Edit(
            title = "文章选择",
            type = EditType.REFERENCE_TABLE,
            referenceTableType = ReferenceTableType(label = "title"),
        ),
    )
    var article: Article? = null

    @ManyToOne
    @EruptField(
        edit = Edit(
            title = "多对一树",
            search = Search(),
            type = EditType.REFERENCE_TREE,
            referenceTreeType = ReferenceTreeType(id = "id", label = "name", pid = "parent.id"),
        ),
    )
    var tree: TreeView? = null

    @EruptField(
        views = [View(title = "标签选择")],
        edit = Edit(title = "标签选择", search = Search(), type = EditType.TAGS),
    )
    var tags: String? = null

    @Transient
    @EruptField(
        edit = Edit(title = "时间选择", type = EditType.DIVIDE),
    )
    var dateDiv: String? = null

    @EruptField(
        views = [View(title = "日期")],
        edit = Edit(
            title = "日期",
            type = EditType.DATE,
            dateType = DateType(type = DateType.Type.DATE),
            search = Search(vague = true),
        ),
    )
    var date1: Date? = null

    @EruptField(
        views = [View(title = "时间日期")],
        edit = Edit(
            title = "时间日期",
            type = EditType.DATE,
            dateType = DateType(type = DateType.Type.DATE_TIME),
            search = Search(vague = true),
        ),
    )
    var dateTime: Date? = null

    @EruptField(
        views = [View(title = "时间")],
        edit = Edit(
            title = "时间",
            type = EditType.DATE,
            dateType = DateType(type = DateType.Type.TIME),
            search = Search(),
        ),
    )
    var time: String? = null

    @EruptField(
        views = [View(title = "周")],
        edit = Edit(
            title = "周",
            type = EditType.DATE,
            dateType = DateType(type = DateType.Type.WEEK),
            search = Search(),
        ),
    )
    var week: String? = null

    @EruptField(
        views = [View(title = "月")],
        edit = Edit(
            title = "月",
            type = EditType.DATE,
            dateType = DateType(type = DateType.Type.MONTH),
            search = Search(),
        ),
    )
    var month: String? = null

    @EruptField(
        views = [View(title = "年")],
        edit = Edit(
            title = "年",
            type = EditType.DATE,
            dateType = DateType(type = DateType.Type.YEAR),
            search = Search(),
        ),
    )
    var year: String? = null

    @EruptField(
        views = [View(title = "过去时间")],
        edit = Edit(
            title = "过去时间",
            type = EditType.DATE,
            dateType = DateType(pickerMode = DateType.PickerMode.HISTORY),
            search = Search(),
        ),
    )
    var history: String? = null

    @EruptField(
        views = [View(title = "未来时间")],
        edit = Edit(
            title = "未来时间",
            type = EditType.DATE,
            dateType = DateType(pickerMode = DateType.PickerMode.FUTURE),
            search = Search(),
        ),
    )
    var feature: String? = null

}